<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>mq_send</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_007_766">&nbsp;</a>NAME</h4><blockquote>
mq_send - send a message to a message queue
(<b>REALTIME</b>)
</blockquote><h4><a name = "tag_000_007_767">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="mqueue.h.html">mqueue.h</a>&gt;

int mq_send(mqd_t <i>mqdes</i>, const char *<i>msg_ptr</i>, size_t <i>msg_len</i>,
    unsigned int <i>msg_prio</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_768">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>mq_send()</i>
function adds the message pointed to by the argument
<i>msg_ptr</i>
to the message queue specified by
<i>mqdes.</i>
The
<i>msg_len</i>
argument specifies the length of the message in bytes pointed to by
<i>msg_ptr</i>.
The value of
<i>msg_len</i>
is less than or equal to the
<i>mq_msgsize</i>
attribute of the message queue, or
<i>mq_send()</i>
fails.
<p>
If the specified message queue is not full,
<i>mq_send()</i>
behaves as if the message is inserted into the message queue at the
position indicated by the
<i>msg_prio</i>
argument.
A message with a larger numeric value of
<i>msg_prio</i>
is inserted before messages with lower values of
<i>msg_prio</i>.
A message will be inserted after other messages in the queue,
if any, with equal
<i>msg_prio</i>.
The value of
<i>msg_prio</i>
will be less than MQ_PRIO_MAX.
<p>
If the specified message queue is full and O_NONBLOCK
is not set in the message queue description associated with
<i>mqdes</i>,
<i>mq_send()</i>
blocks until space becomes available to enqueue the message,
or until
<i>mq_send()</i>
is interrupted by a signal.
If more than one thread 
is waiting to send
when space becomes available in the message queue and the
Priority Scheduling option is supported,
then the thread 
of the highest priority that has been waiting the longest
will be unblocked to send its message.
Otherwise, it is unspecified which waiting thread 
is unblocked.
If the specified message queue is full and O_NONBLOCK
is set in the message queue description associated with
<i>mqdes</i>,
the message is not queued and
<i>mq_send()</i>
returns an error.
</blockquote><h4><a name = "tag_000_007_769">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion, the
<i>mq_send()</i>
function returns a value of zero.
Otherwise, no message is enqueued,
the function returns -1, and
is set to indicate the error.
</blockquote><h4><a name = "tag_000_007_770">&nbsp;</a>ERRORS</h4><blockquote>
The 
<i>mq_send()</i>
function will fail if:
<dl compact>

<dt>[EAGAIN]<dd>
The O_NONBLOCK flag is set in the message queue description associated with
<i>mqdes</i>,
and the specified message queue is full.

<dt>[EBADF]<dd>
The
<i>mqdes</i>
argument is not a valid message queue descriptor open for writing.

<dt>[EINTR]<dd>
A signal interrupted the call to
<i>mq_send()</i>.

<dt>[EINVAL]<dd>
The value of
<i>msg_prio</i>
was outside the valid range.

<dt>[EMSGSIZE]<dd>
The specified message length,
<i>msg_len</i>,
exceeds the message size attribute of the message queue.

<dt>[ENOSYS]<dd>
The function
<i>mq_send()</i>
is not supported by this implementation.

</dl>
</blockquote><h4><a name = "tag_000_007_771">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_772">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_773">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="mq_receive.html">mq_receive()</a></i>,
<i><a href="mq_setattr.html">mq_setattr()</a></i>,
<i><a href="mqueue.h.html">&lt;mqueue.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

